<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<SiteItemViewModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>
        <%= Model.Localize("SiteSettingPageTitle")%>
    </title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%= Html.SuccessNotification("successNotification", Model.Localize("SiteSettingsSuccessNotification"))%>
    <%= Html.ErrorNotification("errorNotification", Model.Localize("SiteSettingsErrorNotification"))%>
    <div class="page-title" id="settings-header">
        <h1>
            <%= Model.Localize("SiteSettingPageHeader")%></h1>
    </div>
    <div class="page-menu">
        <%= Html.UrlActionLink(Model.Localize("SaveLink"), "javascript:void(0);", new { onclick = "Save();" })%>
    </div>
    <div id="site-settings-content">
        <% using (Html.BeginForm(Url.EditSite(Model.Id), new { id = "siteSettingsForm" }))
           { %>
        <div id="accordion" class="accordion">
            <h3>
                <a href="#">
                    <%= Model.Localize("SiteGeneralTabTitle") %></a></h3>
            <div>
                <div class="site-edit-form">
                    <%= Html.EditorFor(m => m.Name)%>
                    <%= Html.EditorFor(m => m.Description)%>
                </div>
            </div>
            <h3>
                <a href="#">
                    <%= Model.Localize("SiteContentTabTitle") %></a></h3>
            <div>
                <div class="site-edit-form">
                    <%= Html.EditorFor(m => m.DefaultPage)%>
                    <%= Html.EditorFor(m => m.LoginPage)%>
                    <%= Html.EditorFor(m => m.AccountPage)%>
                    <%= Html.EditorFor(m => m.Skin)%>
                    <%= Html.EditorFor(m => m.RegistrationType)%>
                    <%= Html.EditorFor(m => m.Culture)%>
                </div>
            </div>
            <h3>
                <a href="#">
                    <%= Model.Localize("SiteSmtpTabTitle") %></a></h3>
            <div>
                <div class="site-edit-form">
                    <%= Html.EditorFor(m => m.Email)%>
                    <%= Html.EditorFor(m => m.SmtpUserName)%>
                    <%= Html.EditorFor(m => m.SmtpPassword)%>
                    <%= Html.EditorFor(m => m.SmtpServer)%>
                    <%= Html.EditorFor(m => m.SmtpServerPort)%>
                </div>
            </div>
            <h3>
                <a href="#">
                    <%= Model.Localize("SiteMetadataTabTitle") %></a></h3>
            <div>
                <div class="site-edit-form">
                    <%= Html.EditorFor(m => m.HeaderText, "TextArea")%>
                    <%= Html.EditorFor(m => m.FooterText, "TextArea")%>
                </div>
            </div>
        </div>
        <%= Html.MvcEngineAntiForgeryToken(m => m.AntiForgeryToken) %>
        <% } %>
    </div>

    <script type="text/javascript">
  	    $(function() {
  	        $("#accordion").accordion({
  	            autoHeight: false
  	        });
  	    });

  	    function Save() {
  	        var options = {
  	            success: function(data) {
  	                var json = JSON.parse(data);
  	                $('.notification').hide('slow');
  	                if (json.model == "invalid") {
  	                    $('#errorNotification').show('fast');
  	                    var result = "<ul>";
  	                    for (var i in json.errors) {
  	                        result += "<li>" + json.errors[i] + "</li>";
  	                    }
  	                    result += "</ul>";
  	                    $('#errorNotification .notification-msg-content').html(result);
  	                }
  	                else {
  	                    $('#successNotification').show('fast');
  	                }
  	            },
  	            error: function(request, textStatus, errorThrown) {
  	                $('.notification').hide('fast');
  	                $('#errorNotification').show('fast');
  	            }
  	        };
  	        $('#siteSettingsForm').ajaxSubmit(options);
  	    }


    
    </script>

</asp:Content>
